import { StrictMode } from 'react';

import { ErrorBoundary } from 'react-error-boundary';

import { createRoot } from 'react-dom/client';

import ErrorPage from '@/components/ErrorBoundary';
import setupNProgress from '@/plugins/nprogress';

import App from './App';
// 导入样式
import 'virtual:uno.css';
import './styles/global.scss';
import '@antv/x6-plugin-transform/dist/index.css';

// createRoot(document.getElementById('root')!).render(
//   <StrictMode>
//     <ConfigProvider locale={zhCN} theme={antdTheme}>
//       <RouterProvider router={router} />
//     </ConfigProvider>
//   </StrictMode>
// );

function setupApp() {
  const container = document.getElementById('root'); // 获取根DOM节点

  if (!container) return; // 如果根节点不存在，直接返回

  const root = createRoot(container); // 创建React根节点
  // 渲染应用
  root.render(
    <ErrorBoundary fallbackRender={ErrorPage}>
      <StrictMode>
        <App />
      </StrictMode>
    </ErrorBoundary>
  );
  setupNProgress();
  console.log('当前环境', import.meta.env);
}

setupApp();
